//
//  AccountHeader.m
//  ArtCircle
//
//  Created by sunbin on 2017/5/18.
//  Copyright © 2017年 Quanli. All rights reserved.
//

#import "AccountHeader.h"


@interface AccountHeader()

@property (nonatomic ,assign) CGFloat titleLabWidth;

@property (nonatomic ,strong) UIView *lineView;

@end

@implementation AccountHeader

- (void)awakeFromNib {
    [super awakeFromNib];
    
    
    
    
}

- (void)layoutSublayersOfLayer:(CALayer *)layer{
    [super layoutSublayersOfLayer:layer];
    
   
    WEAKSELF;
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.left.equalTo(weakSelf.mas_left).with.offset(65);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(-(45/2-1));
        
        make.height.mas_equalTo(@2);
    }];
    
    
    
    
    _titleLabWidth = [self.titleLab.text widthWithFont:[UIFont systemFontOfSize:15.f] constrainedToHeight:45] + 21*2;

    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.bottom.equalTo(weakSelf.mas_bottom).with.offset(0);
        make.size.mas_equalTo(CGSizeMake(weakSelf.titleLabWidth, 45));

    }];
    
    [self bringSubviewToFront:self.titleLab];

}

- (UIView *)lineView{
    
    if (!_lineView) {
        _lineView = [[UIView alloc] init];
        self.lineView.backgroundColor = [UIColor lightGrayColor];
        [self addSubview:_lineView];
    }
    return _lineView;

}

-(UILabel *)titleLab {

    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
        _titleLab.textAlignment = NSTextAlignmentCenter;
        _titleLab.backgroundColor = [UIColor whiteColor];
        _titleLab.tintColor = [UIColor blackColor];
        [self addSubview:_titleLab];
    }
    return _titleLab;
}

@end
